import request from '@/utils/request'

export default {
    // 删除笔记
    deleteNote(id) {
        return request({
            url: `/eduservice/edunote/${id}`,
            method: 'delete'
        })
    },

    // 获取笔记详情
    getNoteById(id) {
        return request({
            url: `/eduservice/edunote/${id}`,
            method: 'get'
        })
    },

    // 分页查询笔记列表
    pageNoteList(current, limit, memberId, isPublic) {
        let url = `/eduservice/edunote/page/${current}/${limit}`
        let params = {}
        if (memberId) {
            params.memberId = memberId
        }
        if (isPublic !== null && isPublic !== undefined) {
            params.isPublic = isPublic
        }
        return request({
            url,
            method: 'get',
            params
        })
    },

    // 设置笔记公开状态
    setNotePublic(id, isPublic) {
        return request({
            url: `/eduservice/edunote/setPublic/${id}/${isPublic}`,
            method: 'put'
        })
    },

    // 搜索笔记
    searchNotes(current, limit, params) {
        let url = `/eduservice/edunote/search`
        let queryParams = {
            current,
            limit,
            ...params
        }
        return request({
            url,
            method: 'get',
            params: queryParams
        })
    }
}





